package com.wanxi.service.front.impl;

import com.wanxi.dao.front.DisplayDao;
import com.wanxi.domain.ResultModel;
import com.wanxi.domain.product.ProductModel;
import com.wanxi.service.front.DisplayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DisplayServiceImpl implements DisplayService {


    @Autowired
    private DisplayDao displayDao;


    @Override
    public int getFrontCount() {
        int count = displayDao.getFrontCount();

       /* ResultModel resultModel = new ResultModel();
        resultModel.setData(count);*/

        return count;
    }

    //跟据书本类型查询书本
    @Override
    public List<ProductModel> findByTypeName(String typeName, int page,int limit) {
        List<ProductModel> lists =  displayDao.findByTypeName( typeName, page, limit);

      /*  ResultModel resultModel = new ResultModel();

        resultModel.setData(lists);*/

        return lists;
    }


    //跟据类型查询产品数量
    @Override
    public int getCountType(String typeName) {
        int count = displayDao.getCountType(typeName);

        ResultModel resultModel = new ResultModel();
        resultModel.setData(count);

        return count;
    }

    //查询上下个分页产品
    @Override
    public List<ProductModel>  findSwitchInfo(int id) {
        List<ProductModel> lists = displayDao.findSwitchInfo(id);

        ResultModel resultModel = new ResultModel();
        resultModel.setData(lists);

        return lists;
    }
}
